<?php
$studentId = $_GET['userid'];
if($studentId == null){
    echo json_encode(array('status'=>401,'msg'=>'参数错误'),JSON_UNESCAPED_UNICODE);
    die;
}
require('../../../cofd/common.php');
require('../../../cofd/functions.php');
$mysqli = $conn;
$query = "SELECT bindteacher FROM exam_student WHERE ID = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("s", $studentId);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$bindteacher = $row['bindteacher'];
$teachers = array_filter(array_map('trim', explode(',', $bindteacher)));
if (count($teachers) > 0) {
    $questionMarks = str_repeat('?,', count($teachers) - 1) . '?'; 
    $query = "SELECT js, mail, name, id FROM exam_user WHERE id IN (" . $questionMarks . ")";
    $stmt = $mysqli->prepare($query);
}
$stmt->bind_param(str_repeat('s', count($teachers)), ...$teachers);
$stmt->execute();
$result = $stmt->get_result();
$teachersData = array();
while ($row = $result->fetch_assoc()) {
    $row['id'] = encrypt($row['id'],'E','teache_byhbindkey721');
    $teachersData[] = $row;
}
$stmt->close();
$mysqli->close();
echo json_encode(array('status'=>200,'teachers' => $teachersData));
?>